package com.kly.sc.api.application.controller.user.request;

import com.fqgj.common.api.ParamsObject;
import com.kly.sc.api.infras.enums.RestCodeEnum;
import com.kly.sc.api.infras.exception.ApplicationException;
import com.kly.user.enums.UserOpActionEnum;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 用户行为接口请求类
 * @author linqu
 */
public class DoUserOperateRequest extends ParamsObject {

    /**
     * 用户内码
     */
    private String userCodeFriend;
    /**
     * 用户操作：1 拉黑  2取消拉黑 3隐藏  4举报
     */
    private Integer opType;
    /**
     * 举报原因, type=4必填
     */
    private String reason;

    /**
     * 用户喜好：1-喜欢 2-不喜欢
     */
    private Integer likeType;

    public Integer getLikeType() {
        return likeType;
    }

    public void setLikeType(Integer likeType) {
        this.likeType = likeType;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Integer getOpType() {
        return opType;
    }

    public void setOpType(Integer opType) {
        this.opType = opType;
    }

    public String getUserCodeFriend() {
        return userCodeFriend;
    }

    public void setUserCodeFriend(String userCodeFriend) {
        this.userCodeFriend = userCodeFriend;
    }


    @Override
    public void validate() {
        if (StringUtils.isBlank(this.userCodeFriend)) {
            throw new ApplicationException(RestCodeEnum.USERID_NOT_EXIST_ERROR);
        }

        if (Objects.isNull(this.opType)) {
            throw new ApplicationException(RestCodeEnum.SYSTEM_PARAMETER_ERROR);
        }
        // 举报时必填
        if (this.opType == UserOpActionEnum.REPORT_USER.getType() && StringUtils.isBlank(this.reason)) {
            throw new ApplicationException(RestCodeEnum.SYSTEM_PARAMETER_ERROR);
        }
    }
}
